import Vue from 'vue'
import Vuex from 'vuex'
import { setItem } from './storage'

Vue.use(Vuex)

export default new Vuex.Store({
  // 公共数据
  state: {
    tokenInfo: {}
  },
  mutations: {
    mSetToken (state, tokenObj) {
      state.tokenInfo = tokenObj

      // 把token信息持久化储存到localStorage中
      setItem('tokenInfo', tokenObj)
    }
  },
  actions: {
  },
  modules: {
  }
})
